package com.onion.utils.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

public class TxtReader {

    public static void readByLines(String srcFile, List<String> fileDatas) {
        File file = new File(srcFile);
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(file));
            String tmpString = null;
            int line = 0;
            //一次读入一行，直到读入null为文件结束
            while ((tmpString=reader.readLine()) != null) {
                // 显示行号
                fileDatas.add(tmpString);
                line++;
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                }
            }
        }
    }

}